package com.woniuxy.house.mapper;

import com.woniuxy.house.entity.HouseDetail;
import com.woniuxy.house.provider.HouseDetailSqlProvider;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

/**
 * 房屋详情的mapper
 */
public interface HouseDetailMapper {
    /**
     *
     * @魏锦鹏
     * 根据房源id查出对应详情
     */
    @Select("select*from house_detail  where id=#{id}")
    @Results(
            {
                    @Result(column = "id",property = "id",id = true),
                    @Result(column = "floor",property = "floor"),
                    @Result(column = "provider_hot",property = "providerHot"),
                    @Result(column = "lift",property = "lift"),
                    @Result(column = "year",property = "year"),
                    @Result(column = "afforest",property = "afforest"),
                    @Result(column = "situation",property = "situation"),
                    @Result(column = "contract",property = "contract"),
					@Result(column = "config",property = "config"),
					@Result(column = "check_in_time",property = "checkInTime"),
					@Result(column = "lease",property = "lease"),
                    @Result(column = "house_description",property = "houseDescription"),
                   // @Result(column = "house_id",property = "source",one = @One(select = "com.woniuxy.house.mapper.SourceMapper.getById",fetchType = FetchType.LAZY))
            }
    )
    HouseDetail selectById(Integer Id);

    /**
     *
     * @魏锦鹏
     * 增加房屋详情
     */
    @Insert("insert into house_detail (id,floor,provider_hot,lift,year,afforest,situation,contract,house_description,config,check_in_time,lease) " +
            "values(#{id},#{floor},#{providerHot},#{lift},#{year},#{afforest},#{situation},#{contract},#{houseDescription},#{config},#{checkInTime},#{lease}) ")
    @Options(useGeneratedKeys=true ,keyColumn="id" ,keyProperty="id")
    void add(HouseDetail houseDetail);

    /**
     * 修改房屋详情
     * @魏锦鹏
     */
    @UpdateProvider(type = HouseDetailSqlProvider.class, method = "update")
    void update(HouseDetail houseDetail);
}
